<!DOCTYPE html>
<html>
<head>
    {include file="../application/common/header.html" /}
</head>

<body>
    <div id="teacher_organize_managetb">
        <form id="teacher_organize_manageForm" class="m5">
            年级：
            <select class="form-control1" name="grade" id="grade"></select>
            学科：
            <select class="form-control1" name="subjectId" id="subjectId"></select>
            教师姓名：
            <input class="form-control1" type="text" name="teacherName" id="teacherName">
            是否绑定：
            <select class="form-control1" name="isBind" id="isBind">
                <option value="">全部</option>
                <option value="0">未绑定</option>
                <option value="1">已绑定</option>
            </select>
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-search'" onclick="searchForm('teacher_organize_manage')">查询</a>
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-clear'" onclick="resetForm('teacher_organize_manage')">重置</a><br/>
        </form>
    </div>
    <table id="teacher_organize_managedg">
        <thead>
            <tr>
                <th data-options="field:'ID',checkbox:true">ID</th>
                <th data-options="field:'action',title:'操作',formatter : function(value,row,index){
                    var str = '<button  type=\'button\' class=\'btn btn-success btn-xs\' style=\'margin:4px 4px;\' onclick=\'createBindEwm('+row.ID+');\'>绑定</button><button  type=\'button\' class=\'btn btn-danger btn-xs\' style=\'margin:4px 4px;\' onclick=\'wechatUnbind('+row.ID+');\'>解绑</button>';
                    return str;
                }"></th>
                <th data-options="field:'姓名',title:'教师姓名'"></th>
                <th data-options="field:'身份证号',title:'身份证号'"></th>
                <th data-options="field:'登录密码',title:'登录密码'"></th>
                <th data-options="field:'年级号',title:'年级号',formatter(value,row,index) {
                    return row.gradeName;
                }"></th>
                <th data-options="field:'任教学科ID',title:'任教学科',formatter(value,row,index) {
                    return row.subjectName;
                }"></th>
                <th data-options="field:'部门',title:'部门',formatter(value,row,index) {
                    return '<span class=\'note\' title=\''+row.departText+'\'>'+ row.departText + '</span>';
                }"></th>
                <th data-options="field:'职位',title:'职位',width: 20,editor:{type:'combobox',options:{
                    valueField:'ID',
                    textField:'POSITION',
                    groupField:'DEPART',
                    method:'get',
                    url: '/compent/Util/organizeDepart',
                    multiple:true,
                    editable:false
                }},formatter(value,row,index) {
                    return '<span class=\'note\' title=\''+row.positionText+'\'>'+ row.positionText + '</span>';
                }"></th>
            </tr>
        </thead>
    </table>
    <div id="bindForm" style="display: none;height: 'auto';">
        <div class="col-md-12 p10" style="text-align: center;">
            <div><p>微信扫一扫 码上绑定</p></div>
            <div><p><img style="width: 50%" id="ewm" src=""/></p></div>
            <div><p>请妥善保管好二维码，不要让陌生人扫描噢！</p></div>
        </div>
    </div>
    <script type="text/javascript">
        var url = "/sysAdmin/teacher_organize_manage";
        $(function(){
            initDatagridAdmin("teacher_organize_manage", url, 0, 0, 1, 1,0,1);
            initGrade("teacher_organize_manage");
            initSubject("teacher_organize_manage");
        })
        function wechatUnbind(id){
            $.ajax({
                url: url + "/wechatUnbind",
                type: 'POST',
                data: {
                    id: id
                }
            }).done(function(data) {
                if(data == '000') {
                    $.messager.show({title:'操作提示',msg: "解绑成功!"});
                    return;
                }
                $.messager.show({title:'操作提示',msg: "解绑成功!"});
            }).fail(function() {
                $.messager.alert('提示', "发生错误请及时联系管理员",'error');
            });
        }
        function createBindEwm(id) {
            $.messager.progress({
                title : '提示',
                msg : '请求中,请稍候...'
            });
            $.ajax({
               type: "POST",
               url: url + "/createBindEwm",
               data: {
                   id: id
               },
               success: function(res){
                   $.messager.progress('close');
                   if(res.code == '000') {
                       $("#ewm").attr("src", res.data);
                       $('#bindForm').dialog({
                            title : '二维码绑定',
                            modal : true,
                            width : 300,
                            top : 100,
                            draggable : true,
                            resizable : true,
                            buttons : '#btns',
                            onClose : function() {
                                $("#ewm").attr("src", "");
                            }
                        }).show();
                   }else {
                        $.messager.alert('提示', res.msg,'error');
                   }
                }
            });
        }
    </script>

</body>
</html>